package com.mlj.controller;

import com.mlj.pojo.Admin;
import com.mlj.service.AdminServiceImpl;
import com.mlj.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    AdminServiceImpl adminService;
    /**
     * 管理员列表页面
     */
    @RequestMapping("/adminlist_page")
    public String adminListPage(){
        return "adminlist";
    }
    /**
     * 管理员信息添加页面
     */
    @RequestMapping("/addadmin_page")
    public String addStudentPage(){
        return "addadmin";
    }
    /**
     * 获取管理员
     */
    @RequestMapping("/selectAdminName")
    @ResponseBody// json格式数据
    public List<Admin> selectClassName(){
        return adminService.getAdminName();
    }
    /**
     *
     * 分页查询列表
     */
    @RequestMapping("/adminlist")
    @ResponseBody// json格式数据
    public Result studentList(Integer page, Integer limit){
        return adminService.getAdminList(page,limit);
    }
    /**
     * 根据id删除
     */
    @RequestMapping("/delAdminById")
    @ResponseBody
    public Result delAdminById(Integer id){
        return adminService.delAdminById(id);
    }
    /**
     * 批量删除
     */
    @RequestMapping("/deleteBatch")
    @ResponseBody
    public Result deleteBatch(Integer [] ids){
        return adminService.deleteBatch(ids);
    }
    /**
     * 添加宿管信息
     */
    @RequestMapping("/addadmin")
    @ResponseBody
    public Result addAdmin(Admin admin){
        return  adminService.addadmin(admin);
    }
    /**
     * 修改宿管信息
     */
    @RequestMapping("/updateadmin")
    @ResponseBody
    public Result updateAdmin(Admin admin){
        return  adminService.updateAdmin(admin);
    }
    /**
     *多条件查询
     */
    @RequestMapping("/search")
    @ResponseBody
    public Result search(String timerange,String keyword,Integer page,Integer limit){
        //System.out.println("时间--"+timerange+"--关键字"+keyword+"--"+page);
        return adminService.search(timerange,keyword,page,limit);
    }
}
